package com.qingyouchuxing.mall.biz.mapper;

import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.qingyouchuxing.mall.biz.domain.entity.MallGoodsSku;
import com.qingyouchuxing.mall.biz.domain.entity.MallGoodsSpu;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

import static com.qingyouchuxing.mall.biz.domain.entity.table.MallGoodsSkuTableDef.MALL_GOODS_SKU;
import static com.qingyouchuxing.mall.biz.domain.entity.table.MallGoodsSpuTableDef.MALL_GOODS_SPU;

@Mapper
public interface MallGoodsSkuMapper extends BaseMapper<MallGoodsSku> {

    /**
     * 根据SpuId查询SKu信息
     * @param fkSpuId spuId
     */
    default List<MallGoodsSku> selectListByFkSpuId(Long fkSpuId){
        QueryWrapper queryWrapper = QueryWrapper.create().where(MALL_GOODS_SKU.FK_SPU_ID.eq(fkSpuId));
        return selectListByQuery(queryWrapper);
    }

    /**
     * 根据SpuId查询SKu信息
     * @param fkSpuId spuId
     */
    default List<MallGoodsSku> selectListByFkSpuId(List<Long> fkSpuId){
        QueryWrapper queryWrapper = QueryWrapper.create().where(MALL_GOODS_SKU.FK_SPU_ID.in(fkSpuId));
        return selectListByQuery(queryWrapper);
    }
}
